/**********************************************************************************************/
/* FBL_DebugNew_DLL.cpp																		  */
/*                                                                       					  */
/* Copyright Paradigma, 1993-2006                                        					  */
/* All Rights Reserved.                                                 					  */
/**********************************************************************************************/
 
// no stdafx.h
//#include <stdafx.h>
#include <new>

// ATTENTION: 
//
// The VClient and VKernel DLLs should include this file to override the standard operators
// new and delete, which calls DebugNew functions from VShared.dll
//
// Problem is that by C++ rules, VShared.dll do NOT export 'operator delete(void *)' and new.
// So for DEBUG targets we need in other DLLs own methods to use our Debugnew system,
// and overide system operators.
 
#if FBL_CLIENT
#include <VClient/prot/Headers/VClientEx.h>
#else
#include <VShared/FBL/publ/Headers/FBL.h>
#endif // FBL_CLIENT
  

/**********************************************************************************************/
// RZ: 10/15/05: Hmm, this should be removed from here somehow...
// 
FBL_Begin_Namespace

#if FBL_STATIC && !FBL_CLIENT && !SKW_VX
	char* gLatestTestFunction;
#endif // FBL_STATIC;

FBL_End_Namespace


/**********************************************************************************************/
/**********************************************************************************************/
/**********************************************************************************************/
/**********************************************************************************************/
// operators new/debug must be enabled only if this file is NOT in the VSHared project.
//
#if !FBL_SHARED_EXPORT

// Only if DebugNew is ON and we make DLL:
//
#if DEBUG_NEW != 0
#if !FBL_STATIC

#undef new

/**********************************************************************************************/
void* operator new(STD::size_t size) throw(STD::bad_alloc)
{
	return fbl_new( size, false );
}

void *operator new(STD::size_t size, const STD::nothrow_t& nt) throw()
{
	return fbl_new( size, nt, false );
}

void *operator new[](STD::size_t size) throw(STD::bad_alloc)
{
	return fbl_new( size, true );
}

void *operator new[](STD::size_t size, const STD::nothrow_t& nt) throw()
{
	return fbl_new( size, nt, true );
}


/**********************************************************************************************/
void operator delete(void* ptr) throw()
{
	fbl_delete( ptr );
}

void operator delete [] (void* ptr) throw()
{
	fbl_delete_array( ptr );
}


/**********************************************************************************************/
#endif //!FBL_STATIC
#endif // DEBUG_NEW


/**********************************************************************************************/
#endif // !FBL_SHARED_EXPORT
